Table of Contents
- Importing Data
- Analysis of experiment metrics
- Heatmap
- Heatmap_reversal
- Strategies
- OLD Graphs
- UPDATED Graphs
- Probe Trial Graphs
- Layout Test
- Arena Quadrant Problem
- t-Tests
- Logistic regression
- Strategy overview plot
- Visualization results log.reg
- Thresholded Logistic regression
- Thresholded Visualization results log.reg
- References
Importing Data
Here a multicore CPU cluster is opened to reduce experiment reading times. This cluster is closed after the execution of the code.
cluster = parallel::makeCluster(rep("localhost", parallel::detectCores()), type = "SOCK")
experiment = Rtrack::read_experiment("Experiment_description2.xlsx", format = "Excel", cluster = cluster)
parallel::stopCluster(cluster)Analysis of experiment metrics
These metrics can be compared and extracted from the pure track files.
experiment$summary.variables [1] "path.length" "mean.velocity"
[3] "sd.velocity" "total.time"
[5] "latency.to.goal" "goal.crossings"
[7] "old.goal.crossings" "coverage"
[9] "mean.d.centroid" "mean.d.goal"
[11] "mean.d.old.goal" "mean.d.origin"
[13] "sd.d.centroid" "sd.d.goal"
[15] "sd.d.old.goal" "sd.d.origin"
[17] "centroid.goal.displacement" "centroid.old.goal.displacement"
[19] "mean.initial.heading.error" "initial.trajectory.error"
[21] "initial.reversal.error" "turning"
[23] "turning.absolute" "efficiency"
[25] "roaming.entropy" "time.in.zone.pool"
[27] "time.in.zone.wall" "time.in.zone.far.wall"
[29] "time.in.zone.annulus" "time.in.zone.goal"
[31] "time.in.zone.old.goal" "time.in.zone.n.quadrant"
[33] "time.in.zone.e.quadrant" "time.in.zone.s.quadrant"
[35] "time.in.zone.w.quadrant"
par(mfrow = c(2, 2))
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Strain", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Age_group", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Housing", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "All", exclude.probe = TRUE,lwd = 2) Note that the probe trials have been omitted from these plots.
Heatmap
wt.metrics = experiment$metrics[experiment$factors$Strain == "WT" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4|
experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
dTg.metrics = experiment$metrics[experiment$factors$Strain == "dTg" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
APP.metrics = experiment$metrics[experiment$factors$Strain == "APPswe" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
PS1.metrics = experiment$metrics[experiment$factors$Strain == "PS1dE9" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
par(mfrow = c(2, 2))
Rtrack::plot_density(wt.metrics, title = "wt Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTg.metrics, title = "dTg Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APP.metrics, title = "APPswe Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1.metrics, title = "PS1dE9 Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Heatmap_reversal
wtr.metrics = experiment$metrics[experiment$factors$Strain == "WT" &
(experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
dTgr.metrics = experiment$metrics[experiment$factors$Strain == "dTg" &
(experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
APPr.metrics = experiment$metrics[experiment$factors$Strain == "APPswe" &
(experiment$factors$`_Day` ==7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
PS1r.metrics = experiment$metrics[experiment$factors$Strain == "PS1dE9" &
(experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
par(mfrow = c(2, 2))
Rtrack::plot_density(wtr.metrics, title = "WT_reversal Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgr.metrics, title = "dTg_reversal Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPr.metrics, title = "APPswe_reversal Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1r.metrics, title = "PS1dE9_reversal Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Strategies
Calling strategies
strategies = Rtrack::call_strategy(experiment$metrics)Thresholding strategies
limits called strategies to those, where confidence is greater than 40%
dim(Rtrack::threshold_strategies(strategies, 0.4)$calls)[1] 4203 12
Plotting strategies of all age groups combined
par(mfrow = c(2, 2))
Rtrack::plot_strategies(strategies, experiment = experiment, factor = "Strain",
exclude.probe = TRUE)Plotting thresholded strategies of all age groups combined
par(mfrow = c(2, 2))
Rtrack::plot_strategies(Rtrack::threshold_strategies(strategies, 0.4), experiment = experiment,
factor = "Strain", exclude.probe = TRUE)Saving the results
Here we export the results of the analyzed Track Files into a data.frame, to analyse them further.
results = Rtrack::export_results(experiment)
datatable(results, rownames = FALSE, filter="top", options = list(pageLength = 5, scrollX=T) )OLD Graphs
Plotting with ggplot2
library(ggplot2)
library(readxl)
Results=read_excel("Results3.xlsx", col_types=c("text","text","text","text","text","text","logical","numeric","text","text","text","numeric","text","numeric","text","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric"))
ggplot(Results, aes(x=`_Day`,y=path.length,color=factor(Strain)))+geom_jitter()Results# A tibble: 5,960 x 60
Track_ID `_TargetID` `_Day` `_Trial` `_Arena` Condition Probe Trial Strain
<chr> <chr> <chr> <chr> <chr> <chr> <lgl> <dbl> <chr>
1 Track_4 60-911 1 1 Arena_SW.t~ WT_STD FALSE 4 WT
2 Track_8 60-293 1 1 Arena_SW.t~ WT_STD FALSE 8 WT
3 Track_9 60-296 1 1 Arena_SW.t~ WT_STD FALSE 9 WT
4 Track_10 60-333 1 1 Arena_SW.t~ dTg_STD FALSE 10 dTg
5 Track_14 60-911 1 2 Arena_SW.t~ WT_STD FALSE 14 WT
6 Track_18 60-293 1 2 Arena_SW.t~ WT_STD FALSE 18 WT
7 Track_19 60-296 1 2 Arena_SW.t~ WT_STD FALSE 19 WT
8 Track_20 60-333 1 2 Arena_SW.t~ dTg_STD FALSE 20 dTg
9 Track_24 60-911 1 3 Arena_SW.t~ WT_STD FALSE 24 WT
10 Track_28 60-293 1 3 Arena_SW.t~ WT_STD FALSE 28 WT
# ... with 5,950 more rows, and 51 more variables: Housing <chr>,
# Age_group <chr>, Age_months <dbl>, All <chr>, strategy <dbl>, name <chr>,
# confidence <dbl>, 1 <dbl>, 2 <dbl>, 3 <dbl>, 4 <dbl>, 5 <dbl>, 6 <dbl>,
# 7 <dbl>, 8 <dbl>, 9 <dbl>, path.length <dbl>, mean.velocity <dbl>,
# sd.velocity <dbl>, total.time <dbl>, latency.to.goal <dbl>,
# goal.crossings <dbl>, old.goal.crossings <dbl>, coverage <dbl>,
# mean.d.centroid <dbl>, mean.d.goal <dbl>, mean.d.old.goal <dbl>,
# mean.d.origin <dbl>, sd.d.centroid <dbl>, sd.d.goal <dbl>,
# sd.d.old.goal <dbl>, sd.d.origin <dbl>, centroid.goal.displacement <dbl>,
# centroid.old.goal.displacement <dbl>, mean.initial.heading.error <dbl>,
# initial.trajectory.error <dbl>, initial.reversal.error <dbl>,
# turning <dbl>, turning.absolute <dbl>, efficiency <dbl>,
# roaming.entropy <dbl>, time.in.zone.pool <dbl>, time.in.zone.wall <dbl>,
# time.in.zone.far.wall <dbl>, time.in.zone.annulus <dbl>,
# time.in.zone.goal <dbl>, time.in.zone.old.goal <dbl>,
# time.in.zone.n.quadrant <dbl>, time.in.zone.e.quadrant <dbl>,
# time.in.zone.s.quadrant <dbl>, time.in.zone.w.quadrant <dbl>
CAREFUL!!! The graphs below still include the probe trials (day 7 trial 1). To remove them add: Probe==‘FALSE’ to filter
Path Length Graphs
WT_STD=filter(Results, Strain=='WT'&Housing=='STD')
dTg_STD=filter(Results, Strain=='dTg'&Housing=='STD')
APP_STD=filter(Results, Strain=='APPswe'&Housing=='STD')
PS_STD=filter(Results, Strain=='PS1dE9'&Housing=='STD')
WT_ENR=filter(Results, Strain=='WT'&Housing=='ENR')
dTg_ENR=filter(Results, Strain=='dTg'&Housing=='ENR')
APP_ENR=filter(Results, Strain=='APPswe'&Housing=='ENR')
PS_ENR=filter(Results, Strain=='PS1dE9'&Housing=='ENR')
par(mfrow = c(2, 4))
WT_STD %>%
mutate(WT_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length WT STD")+scale_fill_jco()dTg_STD %>%
mutate(dTg_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length dTg STD")+scale_fill_jco()APP_STD %>%
mutate(APP_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length APPswe1 STD")+scale_fill_jco()PS_STD %>%
mutate(PS_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length PS1dE9 STD")+scale_fill_jco()WT_ENR %>%
mutate(WT_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length WT ENR")+scale_fill_jco()dTg_ENR %>%
mutate(dTg_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length dTg ENR")+scale_fill_jco()APP_ENR %>%
mutate(APP_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length APPswe1 ENR")+scale_fill_jco()PS_ENR %>%
mutate(PS_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length PS1dE9 ENR")+scale_fill_jco()+
facet_wrap(~Age_group)Latency Graphs
WT_STD %>%
mutate(WT_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s WT STD")+scale_fill_jco()dTg_STD %>%
mutate(dTg_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s dTg STD")+scale_fill_jco()APP_STD %>%
mutate(APP_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s APPswe1 STD")+scale_fill_jco()PS_STD %>%
mutate(PS_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s PS1dE9 STD")+scale_fill_jco()WT_ENR %>%
mutate(WT_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s WT ENR")+scale_fill_jco()dTg_ENR %>%
mutate(dTg_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s dTg ENR")+scale_fill_jco()APP_ENR %>%
mutate(APP_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s APPswe1 ENR")+scale_fill_jco()PS_ENR %>%
mutate(PS_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s PS1dE9 ENR")+scale_fill_jco()+
facet_wrap(~Age_group)UPDATED Graphs
Heatmap_probe
par(mfrow = c(2, 2))
Rtrack::plot_density(wtp.metrics, title = "WT Probe Heatmap 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgp.metrics, title = "dTg Probe Heatmap 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPp.metrics, title = "APPswe Probe Heatmap 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1p.metrics, title = "PS1dE9 Probe Heatmap 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))par(mfrow = c(2, 4))
Rtrack::plot_density(wtpstd.metrics, title = "WT Probe Heatmap STD 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd.metrics, title = "dTg Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpstd.metrics, title = "APPswe Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1pstd.metrics, title = "PS1dE9 Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr.metrics, title = "WT Probe Heatmap ENR 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr.metrics, title = "dTg Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr.metrics, title = "APPswe Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1penr.metrics, title = "PS1dE9 Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100)) WT -> dTg -> APPswe -> PS1dE9
par(mfrow = c(1, 3))
###########WT_Probe##########
Rtrack::plot_density(wtpstd3.metrics, title = "WT Probe Heatmap STD 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpstd14.metrics, title = "WT Probe Heatmap STD 13-14mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpstd25.metrics, title = "WT Probe Heatmap STD 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Rtrack::plot_density(wtpenr3.metrics, title = "WT Probe Heatmap ENR 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr14.metrics, title = "WT Probe Heatmap ENR 13-14mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr25.metrics, title = "WT Probe Heatmap ENR 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))###########dTg_Probe##########
Rtrack::plot_density(dTgpstd3.metrics, title = "dTg Probe Heatmap STD 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd14.metrics, title = "dTg Probe Heatmap STD 13-14mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd25.metrics, title = "dTg Probe Heatmap STD 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Rtrack::plot_density(dTgpenr3.metrics, title = "dTg Probe Heatmap ENR 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr14.metrics, title = "dTg Probe Heatmap ENR 13-14mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr25.metrics, title = "dTg Probe Heatmap ENR 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))###########APP_Probe##########
Rtrack::plot_density(APPpstd3.metrics, title = "APPswe Probe Heatmap STD 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(APPpstd14.metrics, title = "APPswe Probe Heatmap STD 13-14mo",
# col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpstd25.metrics, title = "APPswe Probe Heatmap STD 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr3.metrics, title = "APPswe Probe Heatmap ENR 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))#Rtrack::plot_density(APPpenr14.metrics, title = "APPswe Probe Heatmap ENR 13-14mo",
# col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr25.metrics, title = "APPswe Probe Heatmap ENR 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
###########PS1_Probe##########
Rtrack::plot_density(PS1pstd3.metrics, title = "PS1dE9 Probe Heatmap STD 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(PS1pstd14.metrics, title = "PS1dE9 Probe Heatmap STD 13-14mo",
# col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1pstd25.metrics, title = "PS1dE9 Probe Heatmap STD 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Rtrack::plot_density(PS1penr3.metrics, title = "PS1dE9 Probe Heatmap ENR 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(PS1penr14.metrics, title = "PS1dE9 Probe Heatmap ENR 13-14mo",
# col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1penr25.metrics, title = "PS1dE9 Probe Heatmap ENR 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Path Length Graphs
mo3=filter(Results, Age_group=='3')
mo14=filter(Results, Age_group=='13-14')
mo25=filter(Results, Age_group=='17-25')
mo3 %>%
mutate(mo3, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length 3mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))mo14 %>%
mutate(mo14, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length 13-14mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))mo25 %>%
mutate(mo25, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length 17-25mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#6c7ed7", "dTg_STD" = "#909ef3","WT_ENR" = "#9f48a3", "WT_STD" = "#ce73cf","APPswe_ENR" = "#c85632", "APPswe_STD" = "#e9724b","PS1dE9_ENR" = "#9f9201", "PS1dE9_STD" = "#cab95b"))Boxplot explanation:
Middle line in box -> Median
Box -> shows middle 50% of data(Distance between 1. and 3. Quartil)
Whisker(vertikal lines) -> show upper/lower 25% of data w/o outliers
Points -> outlier
Velocity (Mean) Graphs
mo3=filter(Results, Age_group=='3')
mo14=filter(Results, Age_group=='13-14')
mo25=filter(Results, Age_group=='17-25')
mo3 %>%
mutate(mo3, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Velocity",
title="Mean Velocity 3mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))mo14 %>%
mutate(mo14, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Velocity",
title="Mean Velocity 13-14mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))mo25 %>%
mutate(mo25, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Velocity",
title="Mean Velocity 17-25mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#6c7ed7", "dTg_STD" = "#909ef3","WT_ENR" = "#9f48a3", "WT_STD" = "#ce73cf","APPswe_ENR" = "#c85632", "APPswe_STD" = "#e9724b","PS1dE9_ENR" = "#9f9201", "PS1dE9_STD" = "#cab95b"))Strategy (Thresholded) Graphs
par(mfrow = c(2, 2))
Rtrack::plot_strategies(Rtrack::threshold_strategies(strategies, 0.4), experiment = experiment,
factor = "All", exclude.probe = TRUE)Probe Trial Graphs
Probe Trial Number of Goals Crossings
mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')
mo3.probe %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of Goal Crossings",
title="Probe Trial Number of Goal Crossings 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo14.probe %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of Goal Crossings",
title="Probe Trial Number of Goal Crossings 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo25.probe %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of Goal Crossings",
title="Probe Trial Number of Goal Crossings 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Probe Trial Number of former Goals Crossings
mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')
mo3.probe %>%
ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of old Goal Crossings",
title="Probe Trial Number of former Goal Crossings 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo14.probe %>%
ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of old Goal Crossings",
title="Probe Trial Number of former Goal Crossings 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo25.probe %>%
ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of Old Goal Crossings",
title="Probe Trial Number of former Goal Crossings 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Probe Trial Time in old goal zone
mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')
mo3.probe %>%
ggplot(aes(x=`Strain`,y=time.in.zone.old.goal, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Time in s",
title="Probe Trial Time spent in old goal 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo14.probe %>%
ggplot(aes(x=`Strain`,y=time.in.zone.old.goal, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Time in s",
title="Probe Trial Time spent in old goal 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo25.probe %>%
ggplot(aes(x=`Strain`,y=time.in.zone.old.goal, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Time in s",
title="Probe Trial Time spent in old goal 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Probe Trial Mean Initial heading error
mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')
mo3.probe %>%
ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Initial heading error in %??",
title="Probe Trial Mean Initial heading error 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo14.probe %>%
ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Initial heading error in %??",
title="Probe Trial Mean Initial heading error 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo25.probe %>%
ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Initial heading error in ???",
title="Probe Trial Mean Initial heading error 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Probe Trial Mean Distance old goal
3 Months
mo3.probe %>%
ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Distance",
title="Probe Trial Mean Distance old goal 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))13-14 Months
mo14.probe %>%
ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Distance",
title="Probe Trial Mean Distance old goal 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))17-25 Months
mo25.probe %>%
ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Distance",
title="Probe Trial Mean Distance old goal 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Arena Quadrant Problem
knitr::include_graphics("Watermaze_Setup.png") In Ethovision those Quadrants are marked (NE, SE, SW, NW).
In contrast to that, the quadrants that can be analyzed with RTrack are called as below:
“time.in.zone.n.quadrant”
“time.in.zone.e.quadrant”
“time.in.zone.s.quadrant”
“time.in.zone.w.quadrant”
knitr::include_graphics("Watermaze_Quadrant.png")t-Tests
t-Tests (time in old goal zone of probe trials) between Age Groups
3 / 13-14
t.test(mo3.probe$time.in.zone.old.goal,mo14.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: mo3.probe$time.in.zone.old.goal and mo14.probe$time.in.zone.old.goal
t = 0.41802, df = 55.572, p-value = 0.6775
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.4742248 0.7242732
sample estimates:
mean of x mean of y
1.248872 1.123847
3 / 17-25
t.test(mo3.probe$time.in.zone.old.goal,mo25.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: mo3.probe$time.in.zone.old.goal and mo25.probe$time.in.zone.old.goal
t = -0.76178, df = 53.252, p-value = 0.4496
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.8365670 0.3759891
sample estimates:
mean of x mean of y
1.248872 1.479161
13-14 / 17-25
t.test(mo14.probe$time.in.zone.old.goal,mo25.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: mo14.probe$time.in.zone.old.goal and mo25.probe$time.in.zone.old.goal
t = -0.96822, df = 62.942, p-value = 0.3366
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.0886658 0.3780395
sample estimates:
mean of x mean of y
1.123847 1.479161
no significance between the overall groups
t-Tests (time in old goal zone of probe trials) between Strains & Housings of Age Group 17-25
17-25 WT STD/ENR
WTS.mo25.probe=filter(mo25.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo25.probe=filter(mo25.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo25.probe$time.in.zone.old.goal,WTE.mo25.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: WTS.mo25.probe$time.in.zone.old.goal and WTE.mo25.probe$time.in.zone.old.goal
t = 1.2667, df = 15.225, p-value = 0.2243
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.5876549 2.3148994
sample estimates:
mean of x mean of y
2.196897 1.333275
13-14 WT STD/ENR
WTS.mo14.probe=filter(mo14.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo14.probe=filter(mo14.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo14.probe$time.in.zone.old.goal,WTE.mo14.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: WTS.mo14.probe$time.in.zone.old.goal and WTE.mo14.probe$time.in.zone.old.goal
t = -0.4615, df = 11.792, p-value = 0.6528
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.172106 1.414007
sample estimates:
mean of x mean of y
1.278296 1.657345
3 WT STD/ENR
WTS.mo3.probe=filter(mo3.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo3.probe=filter(mo3.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo3.probe$time.in.zone.old.goal,WTE.mo3.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: WTS.mo3.probe$time.in.zone.old.goal and WTE.mo3.probe$time.in.zone.old.goal
t = 0.86513, df = 16.892, p-value = 0.3991
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.8315724 1.9866145
sample estimates:
mean of x mean of y
1.724105 1.146584
no significance found
t-Tests (Path length of all trials) between Strains
17-25 WT/dTg
mo25.WT=filter(mo25, Strain=="WT")
mo25.dTg=filter(mo25, Strain=="dTg")
t.test(mo25.WT$path.length,mo25.dTg$path.length)
Welch Two Sample t-test
data: mo25.WT$path.length and mo25.dTg$path.length
t = -7.4557, df = 286.47, p-value = 1.067e-12
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-333.6846 -194.2992
sample estimates:
mean of x mean of y
667.5763 931.5682
17-25 WT/PS1dE9
mo25.WT=filter(mo25, Strain=="WT")
mo25.PS=filter(mo25, Strain=="PS1dE9")
t.test(mo25.WT$path.length,mo25.PS$path.length)
Welch Two Sample t-test
data: mo25.WT$path.length and mo25.PS$path.length
t = -2.4789, df = 228.85, p-value = 0.0139
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-183.21674 -20.94064
sample estimates:
mean of x mean of y
667.5763 769.6550
17-25 WT/APPswe
mo25.WT=filter(mo25, Strain=="WT")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.WT$path.length,mo25.AP$path.length)
Welch Two Sample t-test
data: mo25.WT$path.length and mo25.AP$path.length
t = -3.6486, df = 268.81, p-value = 0.0003167
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-217.38161 -65.00338
sample estimates:
mean of x mean of y
667.5763 808.7688
17-25 PS1dE9/APPswe
mo25.PS=filter(mo25, Strain=="PS1dE9")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.PS$path.length,mo25.AP$path.length)
Welch Two Sample t-test
data: mo25.PS$path.length and mo25.AP$path.length
t = -0.7493, df = 357.63, p-value = 0.4542
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-141.77175 63.54414
sample estimates:
mean of x mean of y
769.6550 808.7688
17-25 dTg/PS1dE9
mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="PS1dE9")
t.test(mo25.dTg$path.length,mo25.PS$path.length)
Welch Two Sample t-test
data: mo25.dTg$path.length and mo25.PS$path.length
t = 3.2506, df = 343.79, p-value = 0.001266
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
63.94184 259.88464
sample estimates:
mean of x mean of y
931.5682 769.6550
17-25 dTg/APPswe
mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.dTg$path.length,mo25.AP$path.length)
Welch Two Sample t-test
data: mo25.dTg$path.length and mo25.AP$path.length
t = 2.5701, df = 380.87, p-value = 0.01055
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
28.85462 216.74425
sample estimates:
mean of x mean of y
931.5682 808.7688
t-Tests (Latency to goal of all trials) between Strains
17-25 WT/dTg
mo25.WT=filter(mo25, Strain=="WT")
mo25.dTg=filter(mo25, Strain=="dTg")
t.test(mo25.WT$latency.to.goal,mo25.dTg$latency.to.goal)
Welch Two Sample t-test
data: mo25.WT$latency.to.goal and mo25.dTg$latency.to.goal
t = -1.2135, df = 75.087, p-value = 0.2287
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-7.80585 1.89582
sample estimates:
mean of x mean of y
21.66102 24.61604
17-25 WT/PS1dE9
mo25.WT=filter(mo25, Strain=="WT")
mo25.PS=filter(mo25, Strain=="PS1dE9")
t.test(mo25.WT$latency.to.goal,mo25.PS$latency.to.goal)
Welch Two Sample t-test
data: mo25.WT$latency.to.goal and mo25.PS$latency.to.goal
t = 0.20491, df = 121.95, p-value = 0.838
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-3.458770 4.257498
sample estimates:
mean of x mean of y
21.66102 21.26166
17-25 WT/APPswe
mo25.WT=filter(mo25, Strain=="WT")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.WT$latency.to.goal,mo25.AP$latency.to.goal)
Welch Two Sample t-test
data: mo25.WT$latency.to.goal and mo25.AP$latency.to.goal
t = -0.54994, df = 133.82, p-value = 0.5833
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-4.522667 2.554791
sample estimates:
mean of x mean of y
21.66102 22.64496
17-25 PS1dE9/APPswe
mo25.PS=filter(mo25, Strain=="PS1dE9")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.PS$latency.to.goal,mo25.AP$latency.to.goal)
Welch Two Sample t-test
data: mo25.PS$latency.to.goal and mo25.AP$latency.to.goal
t = -0.56912, df = 180.51, p-value = 0.57
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-6.179354 3.412750
sample estimates:
mean of x mean of y
21.26166 22.64496
17-25 dTg/PS1dE9
mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="PS1dE9")
t.test(mo25.dTg$latency.to.goal,mo25.PS$latency.to.goal)
Welch Two Sample t-test
data: mo25.dTg$latency.to.goal and mo25.PS$latency.to.goal
t = 1.1414, df = 127.49, p-value = 0.2558
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.460675 9.169433
sample estimates:
mean of x mean of y
24.61604 21.26166
17-25 dTg/APPswe
mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.dTg$latency.to.goal,mo25.AP$latency.to.goal)
Welch Two Sample t-test
data: mo25.dTg$latency.to.goal and mo25.AP$latency.to.goal
t = 0.69518, df = 118.95, p-value = 0.4883
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-3.643181 7.585335
sample estimates:
mean of x mean of y
24.61604 22.64496
Logistic regression
Results table can be seen here
Strategy Legend
- 1 - thigmotaxis
- 2 - circling
- 3 - random path
- 4 - scanning
- 5 - chaining
- 6 - directed search
- 7 - corrected search
- 8 - direct path
- 9 - perseverance
Strategies 1-5 are less hippocampus-dependent, ‘unspatial’ and therefore get strategy.class = 0. In contrast to that, strategies 6-9 are more hippocampus-dependent, ‘spatial’ and get strategy.class = 1 assigned.
All probabilities in the following codes relate to choosing strategy.class = 1.
setwd("C:/Google/Uni/Bachelorarbeit/R/Analysis")
logistic.data=read_excel("logistic.reg.xlsx")Age group 17-25 Housing
logistic.data.1725=filter(logistic.data, Age_group1725=='1')fitting different logistic regression models with increasing complexity
simple model including housing only
logreg.1725.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1725)simple model including Strain only
logreg.1725.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1725)additive model including all factors
logreg.1725.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1725)interaction model including all factors
logreg.1725.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1725)Model comparisons using the anova function
anova(logreg.1725.add.1b, logreg.1725.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1308 1775.6
2 1310 1811.7 -2 -36.096 1.452e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model including Strain better than model including housing
anova(logreg.1725.add.2, logreg.1725.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1307 1774.6
2 1308 1775.6 -1 -1.0162 0.3134
adding factor housing does not improve the model
anova(logreg.1725.int, logreg.1725.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1304 1771.3
2 1308 1775.6 -4 -4.3588 0.3596
interaction model not better than additive model simple model including Strain only is the minimal adequate model
summary of minimal adequate model
summary(logreg.1725.add.1b)
Call:
glm(formula = strategy.class ~ Strain, family = binomial, data = logistic.data.1725)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.325 -1.222 1.037 1.037 1.475
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.10318 0.14378 0.718 0.472979
StraindTg -0.78083 0.20945 -3.728 0.000193 ***
StrainPS1dE9 -0.03339 0.20966 -0.159 0.873472
StrainWT 0.23739 0.16168 1.468 0.142040
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1813.9 on 1311 degrees of freedom
Residual deviance: 1775.6 on 1308 degrees of freedom
AIC: 1783.6
Number of Fisher Scoring iterations: 4
exp(coef(logreg.1725.add.1b)) (Intercept) StraindTg StrainPS1dE9 StrainWT
1.1086957 0.4580270 0.9671628 1.2679321
impact of predictor “Strain”
pred.data <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pred.data$prob <- predict(logreg.1725.add.1b, newdata = pred.data, type = "response")
pred.data Strain prob
1 WT 0.5843293
2 dTg 0.3367876
3 PS1dE9 0.5174419
4 APPswe 0.5257732
impact of predictor “housing”
pred.data2 <- data.frame(Housing=c("STD","ENR"))
pred.data2$prob <- predict(logreg.1725.add.1a, newdata = pred.data2, type = "response")
pred.data2 Housing prob
1 STD 0.5504451
2 ENR 0.5094044
Age group 13-14 Strain x Housing effects
logistic.data.1314=filter(logistic.data, Age_group1314=='1')fitting different logistic regression models with increasing complexity simple model including housing only
logreg.1314.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1314)simple model including Strain only
logreg.1314.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1314)additive model including all factors
logreg.1314.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1314)interaction model including all factors
logreg.1314.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1314)model comparisons using the anova function
anova(logreg.1314.add.1b, logreg.1314.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1306 1724.2
2 1306 1804.4 0 -80.16
no Df, same model fit?
anova(logreg.1314.add.2, logreg.1314.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1305 1718.1
2 1306 1724.2 -1 -6.1765 0.01295 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
additive model shows significantly better fit (Pr=0.01295)
anova(logreg.1314.int, logreg.1314.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1304 1712.2
2 1306 1724.2 -2 -11.999 0.00248 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than simple Strain model (Pr=0.00248) interaction model including Strain*Housing is the best fitting model
summary of minimal adequate model
summary(logreg.1314.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.1314)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.4842 -0.9285 -0.9253 1.1143 1.4525
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.626772 0.118643 -5.283 1.27e-07 ***
HousingSTD 0.008426 0.167152 0.050 0.9598
StrainWT 1.324112 0.163290 8.109 5.11e-16 ***
HousingSTD:StrainWT -0.555484 0.230430 -2.411 0.0159 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1811.7 on 1307 degrees of freedom
Residual deviance: 1712.3 on 1304 degrees of freedom
AIC: 1720.3
Number of Fisher Scoring iterations: 4
exp(coef(logreg.1314.int)) (Intercept) HousingSTD StrainWT HousingSTD:StrainWT
0.5343137 1.0084617 3.7588467 0.5737945
impact of predictor "Strain*Housing"
pred.data1314 <- data.frame(Strain=c("WT", "WT","dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pred.data1314$prob <- predict(logreg.1314.int, newdata = pred.data1314, type = "response")
pred.data1314 Strain Housing prob
1 WT STD 0.5375000
2 WT ENR 0.6675978
3 dTg STD 0.3501577
4 dTg ENR 0.3482428
Age group 3 Strain x Housing
logistic.data.3=filter(logistic.data, Age_group3=='1')fitting different logistic regression models with increasing complexity simple model including housing only
logreg.3.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.3)simple model including Strain only
logreg.3.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.3)additive model including all factors
logreg.3.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.3)interaction model including all factors
logreg.3.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.3)comparisons between model using the anova function
anova(logreg.3.add.1b, logreg.3.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 3336 4458.5
2 3338 4516.0 -2 -57.513 3.245e-13 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model with Strain only is really good (Pr=3.245e-13)
anova(logreg.3.add.2, logreg.3.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 3335 4440.3
2 3336 4458.5 -1 -18.243 1.945e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adding factor housing also has good fit (Pr=1.945e-5)
anova(logreg.3.int, logreg.3.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 3332 4428.8
2 3336 4458.5 -4 -29.694 5.648e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than additive model (Pr=5.648e-6) interaction model is the best
summary of Strain only model
summary(logreg.3.add.1b)
Call:
glm(formula = strategy.class ~ Strain, family = binomial, data = logistic.data.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.4508 -1.3122 0.9267 1.0483 1.2183
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.31144 0.06899 4.514 6.35e-06 ***
StraindTg -0.40719 0.09715 -4.192 2.77e-05 ***
StrainPS1dE9 0.31166 0.09914 3.143 0.00167 **
StrainWT 0.30702 0.10290 2.984 0.00285 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 4529.0 on 3339 degrees of freedom
Residual deviance: 4458.5 on 3336 degrees of freedom
AIC: 4466.5
Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.add.1b)) (Intercept) StraindTg StrainPS1dE9 StrainWT
1.3653846 0.6655165 1.3656859 1.3593683
summary of interaction model
summary(logreg.3.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.5713 -1.2014 0.8293 1.0221 1.2715
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.571375 0.099833 5.723 1.04e-08 ***
HousingSTD -0.515022 0.139153 -3.701 0.000215 ***
StraindTg -0.567129 0.135864 -4.174 2.99e-05 ***
StrainPS1dE9 0.319191 0.145466 2.194 0.028217 *
StrainWT -0.008040 0.153664 -0.052 0.958274
HousingSTD:StraindTg 0.292295 0.195814 1.493 0.135512
HousingSTD:StrainPS1dE9 0.001266 0.200208 0.006 0.994953
HousingSTD:StrainWT 0.610701 0.207830 2.938 0.003298 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 4529.0 on 3339 degrees of freedom
Residual deviance: 4428.8 on 3332 degrees of freedom
AIC: 4444.8
Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.int)) (Intercept) HousingSTD StraindTg
1.7707006 0.5974872 0.5671514
StrainPS1dE9 StrainWT HousingSTD:StraindTg
1.3760135 0.9919925 1.3394975
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
1.0012672 1.8417220
impact of predictor “Strain”
pred.data3 <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pred.data3$prob <- predict(logreg.3.add.1b, newdata = pred.data3, type = "response")
pred.data3 Strain prob
1 WT 0.6498674
2 dTg 0.4760793
3 PS1dE9 0.6509217
4 APPswe 0.5772358
impact of predictors “Strain x Housing”
pred.data3x <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pred.data3x$prob <- predict(logreg.3.int, newdata = pred.data3x, type = "response")
pred.data3x Strain Housing prob
1 WT STD 0.6590389
2 WT ENR 0.6372240
3 dTg STD 0.4455959
4 dTg ENR 0.5010616
5 PS1dE9 STD 0.5931034
6 PS1dE9 ENR 0.7090069
7 APPswe STD 0.5140845
8 APPswe ENR 0.6390805
The full overview of the logistic regression results table is here.
Age group 17-25 acquisition Strain
logistic.data.1725.acq=filter(logistic.data.1725, `_Day`=='1'|`_Day`=='2'|`_Day`=='3'|`_Day`=='4'|`_Day`=='5'|`_Day`=='6')fitting different logistic regression models with increasing complexity
simple model including housing only
logreg.1725.acq.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1725.acq)simple model including Strain only
logreg.1725.acq.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1725.acq)additive model including all factors
logreg.1725.acq.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1725.acq)interaction model including all factors
logreg.1725.acq.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1725.acq)Model comparisons using the anova function
anova(logreg.1725.acq.add.1b, logreg.1725.acq.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 788 1067.9
2 790 1088.0 -2 -20.051 4.427e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model including Strain better than model including housing
anova(logreg.1725.acq.add.2, logreg.1725.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 787 1067.9
2 788 1067.9 -1 -0.016692 0.8972
adding factor housing does not improve the model
anova(logreg.1725.acq.int, logreg.1725.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 784 1063.0
2 788 1067.9 -4 -4.9469 0.2928
summary(logreg.1725.acq.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.1725.acq)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.1632 -1.1575 -0.8672 1.1974 1.8182
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.69315 0.30619 -2.264 0.0236 *
HousingSTD 0.63599 0.38851 1.637 0.1016
StraindTg -0.09097 0.40387 -0.225 0.8218
StrainPS1dE9 0.59471 0.39935 1.489 0.1364
StrainWT 0.64619 0.33547 1.926 0.0541 .
HousingSTD:StraindTg -1.29223 0.59810 -2.161 0.0307 *
HousingSTD:StrainPS1dE9 -0.70460 0.54826 -1.285 0.1987
HousingSTD:StrainWT -0.62265 0.43190 -1.442 0.1494
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1088.1 on 791 degrees of freedom
Residual deviance: 1063.0 on 784 degrees of freedom
AIC: 1079
Number of Fisher Scoring iterations: 4
exp(coef(logreg.1725.acq.int)) (Intercept) HousingSTD StraindTg
0.5000000 1.8888889 0.9130435
StrainPS1dE9 StrainWT HousingSTD:StraindTg
1.8125000 1.9082569 0.2746572
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
0.4943049 0.5365216
impact of predictor “Strain”
pred.data.17.acq <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pred.data.17.acq$prob <- predict(logreg.1725.acq.add.1b, newdata = pred.data.17.acq, type = "response")
pred.data.17.acq Strain prob
1 WT 0.4900222
2 dTg 0.2631579
3 PS1dE9 0.4678899
4 APPswe 0.4237288
impact of predictor “Housing”
pred.data.17.acq <- data.frame(Housing=c("STD","ENR"))
pred.data.17.acq$prob <- predict(logreg.1725.acq.add.1a, newdata = pred.data.17.acq, type = "response")
pred.data.17.acq Housing prob
1 STD 0.4516129
2 ENR 0.4370180
Age group 17-25 reversal Strain
logistic.data.1725.rev=filter(logistic.data.1725, `_Day`=='7'|`_Day`=='8'|`_Day`=='9'|`_Day`=='10')fitting different logistic regression models with increasing complexity
simple model including housing only
logreg.1725.rev.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1725.rev)simple model including Strain only
logreg.1725.rev.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1725.rev)additive model including all factors
logreg.1725.rev.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1725.rev)interaction model including all factors
logreg.1725.rev.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1725.rev)Model comparisons using the anova function
anova(logreg.1725.rev.add.1b, logreg.1725.rev.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 516 643.08
2 518 662.36 -2 -19.28 6.509e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model including Strain better than model including housing
anova(logreg.1725.rev.add.2, logreg.1725.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 515 641.11
2 516 643.08 -1 -1.9658 0.1609
adding factor housing does not improve the model
anova(logreg.1725.rev.int, logreg.1725.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 512 627.21
2 516 643.08 -4 -15.869 0.003201 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than additive model
summary of minimal adequate model
summary(logreg.1725.rev.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.1725.rev)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.6567 -1.2049 0.7647 0.8340 1.6033
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.79851 0.40139 1.989 0.046660 *
HousingSTD -0.04082 0.50895 -0.080 0.936071
StraindTg -1.75992 0.51715 -3.403 0.000666 ***
StrainPS1dE9 -0.73397 0.53877 -1.362 0.173105
StrainWT 0.28141 0.44533 0.632 0.527444
HousingSTD:StraindTg 1.79069 0.71471 2.505 0.012229 *
HousingSTD:StrainPS1dE9 0.76474 0.73051 1.047 0.295166
HousingSTD:StrainWT -0.16186 0.57128 -0.283 0.776929
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 665.61 on 519 degrees of freedom
Residual deviance: 627.21 on 512 degrees of freedom
AIC: 643.21
Number of Fisher Scoring iterations: 4
exp(coef(logreg.1725.rev.int)) (Intercept) HousingSTD StraindTg
2.2222222 0.9600000 0.1720588
StrainPS1dE9 StrainWT HousingSTD:StraindTg
0.4800000 1.3250000 5.9935897
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
2.1484375 0.8505620
impact of predictor “Strain”
pred.data.17.revs <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pred.data.17.revs$prob <- predict(logreg.1725.rev.int, newdata = pred.data.17.revs, type = "response")
pred.data.17.revs Strain Housing prob
1 WT STD 0.7062500
2 WT ENR 0.7464789
3 dTg STD 0.6875000
4 dTg ENR 0.2765957
5 PS1dE9 STD 0.6875000
6 PS1dE9 ENR 0.5161290
7 APPswe STD 0.6808511
8 APPswe ENR 0.6896552
Age group 13-14 acquisition Strain x Housing
logistic.data.acq.1314=filter(logistic.data.1314, `_Day`=='1'|`_Day`=='2'|`_Day`=='3'|`_Day`=='4'|`_Day`=='5'|`_Day`=='6')fitting different logistic regression models with increasing complexity simple model including housing only
logreg.1314.acq.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.acq.1314)simple model including Strain only
logreg.1314.acq.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.acq.1314)additive model including all factors
logreg.1314.acq.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.acq.1314)interaction model including all factors
logreg.1314.acq.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.acq.1314)comparisons between model using the anova function
anova(logreg.1314.acq.add.1b, logreg.1314.acq.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 779 1014.5
2 779 1049.4 0 -34.833
model with Strain only is good
anova(logreg.1314.acq.add.2, logreg.1314.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 778 1009.0
2 779 1014.5 -1 -5.5851 0.01811 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adding factor housing also has good fit
anova(logreg.1314.acq.int, logreg.1314.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 777 1008.2
2 779 1014.5 -2 -6.3566 0.04166 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
additive model better than interaction model additive model is the best
summary of interactive model
summary(logreg.1314.acq.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.acq.1314)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.2994 -1.0987 -0.7931 1.2582 1.6186
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.7916 0.1583 -5.001 5.70e-07 ***
HousingSTD -0.2038 0.2278 -0.895 0.371
StrainWT 1.0738 0.2100 5.112 3.18e-07 ***
HousingSTD:StrainWT -0.2664 0.3033 -0.878 0.380
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1055.6 on 780 degrees of freedom
Residual deviance: 1008.2 on 777 degrees of freedom
AIC: 1016.2
Number of Fisher Scoring iterations: 4
exp(coef(logreg.1314.acq.int)) (Intercept) HousingSTD StrainWT HousingSTD:StrainWT
0.4531250 0.8155922 2.9265367 0.7660990
impact of predictors “Strain x Housing”
pred.data1314.acq <- data.frame(Strain=c("WT","WT", "dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pred.data1314.acq$prob <- predict(logreg.1314.acq.add.2, newdata = pred.data1314.acq, type = "response")
pred.data1314.acq Strain Housing prob
1 WT STD 0.4682013
2 WT ENR 0.5565671
3 dTg STD 0.2545257
4 dTg ENR 0.3273906
Age group 13-14 reversal Strain x Housing
logistic.data.rev.1314=filter(logistic.data.1314, `_Day`=='7'|`_Day`=='8'|`_Day`=='9'|`_Day`=='10')fitting different logistic regression models with increasing complexity simple model including housing only
logreg.1314.rev.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.rev.1314)simple model including Strain only
logreg.1314.rev.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.rev.1314)additive model including all factors
logreg.1314.rev.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.rev.1314)interaction model including all factors
logreg.1314.rev.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.rev.1314)comparisons between model using the anova function
anova(logreg.1314.rev.add.1b, logreg.1314.rev.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 525 659.45
2 525 710.30 0 -50.855
anova(logreg.1314.rev.add.2, logreg.1314.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 524 658.28
2 525 659.45 -1 -1.1655 0.2803
adding factor does not improve model
anova(logreg.1314.rev.int, logreg.1314.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 523 650.44
2 525 659.45 -2 -9.01 0.01105 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than additive model interaction model is the best
summary of interaction model
summary(logreg.1314.rev.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.rev.1314)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.8297 -1.1247 0.6444 0.9049 1.3508
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.3989 0.1810 -2.204 0.02754 *
HousingSTD 0.2737 0.2533 1.081 0.27974
StrainWT 1.8652 0.2799 6.664 2.67e-11 ***
HousingSTD:StrainWT -1.0586 0.3805 -2.783 0.00539 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 711.87 on 526 degrees of freedom
Residual deviance: 650.44 on 523 degrees of freedom
AIC: 658.44
Number of Fisher Scoring iterations: 4
exp(coef(logreg.1314.rev.int)) (Intercept) HousingSTD StrainWT HousingSTD:StrainWT
0.6710526 1.3148789 6.4575163 0.3469306
impact of predictors “Strain x Housing”
pred.data1314.rev <- data.frame(Strain=c("WT","WT", "dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pred.data1314.rev$prob <- predict(logreg.1314.rev.int, newdata = pred.data1314.rev, type = "response")
pred.data1314.rev Strain Housing prob
1 WT STD 0.6640625
2 WT ENR 0.8125000
3 dTg STD 0.4687500
4 dTg ENR 0.4015748
Age group 3 acquisition Strain x Housing
logistic.data.acq.3=filter(logistic.data.3, `_Day`=='1'|`_Day`=='2'|`_Day`=='3'|`_Day`=='4'|`_Day`=='5'|`_Day`=='6')fitting different logistic regression models with increasing complexity simple model including housing only
logreg.3.acq.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.acq.3)simple model including Strain only
logreg.3.acq.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.acq.3)additive model including all factors
logreg.3.acq.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.acq.3)interaction model including all factors
logreg.3.acq.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.acq.3)comparisons between model using the anova function
anova(logreg.3.acq.add.1b, logreg.3.acq.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1989 2683.6
2 1991 2753.3 -2 -69.785 7.021e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model with Strain only is really good
anova(logreg.3.acq.add.2, logreg.3.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1988 2668.9
2 1989 2683.6 -1 -14.652 0.0001293 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adding factor housing also has good fit
anova(logreg.3.acq.int, logreg.3.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1985 2653.5
2 1989 2683.6 -4 -30.063 4.752e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than additive model interaction model is the best
summary of interaction model
summary(logreg.3.acq.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.acq.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.412 -1.234 0.960 1.089 1.624
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.30111 0.12520 2.405 0.016175 *
HousingSTD -0.59571 0.17841 -3.339 0.000841 ***
StraindTg -0.66816 0.17434 -3.832 0.000127 ***
StrainPS1dE9 0.23441 0.17942 1.307 0.191370
StrainWT -0.08980 0.19226 -0.467 0.640462
HousingSTD:StraindTg -0.04436 0.26255 -0.169 0.865840
HousingSTD:StrainPS1dE9 0.19165 0.25270 0.758 0.448197
HousingSTD:StrainWT 0.89318 0.26355 3.389 0.000701 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 2762.8 on 1992 degrees of freedom
Residual deviance: 2653.5 on 1985 degrees of freedom
AIC: 2669.5
Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.acq.int)) (Intercept) HousingSTD StraindTg
1.3513514 0.5511724 0.5126506
StrainPS1dE9 StrainWT HousingSTD:StraindTg
1.2641667 0.9141176 0.9566127
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
1.2112495 2.4428887
impact of predictors “Strain x Housing”
pred.data3.acq <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pred.data3.acq$prob <- predict(logreg.3.acq.int, newdata = pred.data3.acq, type = "response")
pred.data3.acq Strain Housing prob
1 WT STD 0.6245211
2 WT ENR 0.5526316
3 dTg STD 0.2675439
4 dTg ENR 0.4092527
5 PS1dE9 STD 0.5328185
6 PS1dE9 ENR 0.6307692
7 APPswe STD 0.4268775
8 APPswe ENR 0.5747126
Age group 3 reversal Strain x Housing
logistic.data.rev.3=filter(logistic.data.3, `_Day`=='7'|`_Day`=='8'|`_Day`=='9'|`_Day`=='10')fitting different logistic regression models with increasing complexity simple model including housing only
logreg.3.rev.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.rev.3)simple model including Strain only
logreg.3.rev.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.rev.3)additive model including all factors
logreg.3.rev.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.rev.3)interaction model including all factors
logreg.3.rev.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.rev.3)comparisons between model using the anova function
anova(logreg.3.rev.add.1b, logreg.3.rev.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1343 1614.9
2 1345 1618.3 -2 -3.3859 0.184
model with Strain only is really good (Pr=3.245e-13)
anova(logreg.3.rev.add.2, logreg.3.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1342 1609.6
2 1343 1614.9 -1 -5.326 0.02101 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adding factor housing also has good fit (Pr=1.945e-5)
anova(logreg.3.rev.int, logreg.3.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1339 1598.6
2 1343 1614.9 -4 -16.331 0.002606 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than additive model (Pr=5.648e-6) interaction model is the best
summary of interaction model
summary(logreg.3.rev.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.rev.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.8720 -1.4233 0.7836 0.8752 0.9500
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.0234 0.1719 5.953 2.63e-09 ***
HousingSTD -0.4410 0.2339 -1.886 0.0593 .
StraindTg -0.4617 0.2287 -2.019 0.0435 *
StrainPS1dE9 0.5383 0.2643 2.036 0.0417 *
StrainWT 0.1501 0.2705 0.555 0.5790
HousingSTD:StraindTg 0.7387 0.3282 2.251 0.0244 *
HousingSTD:StrainPS1dE9 -0.3585 0.3481 -1.030 0.3031
HousingSTD:StrainWT 0.1640 0.3549 0.462 0.6441
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1622.9 on 1346 degrees of freedom
Residual deviance: 1598.6 on 1339 degrees of freedom
AIC: 1614.6
Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.rev.int)) (Intercept) HousingSTD StraindTg
2.7826087 0.6433972 0.6302083
StrainPS1dE9 StrainWT HousingSTD:StraindTg
1.7130208 1.1619792 2.0931950
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
0.6987137 1.1781761
impact of predictors “Strain x Housing”
pred.data3.rev <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pred.data3.rev$prob <- predict(logreg.3.rev.int, newdata = pred.data3.rev, type = "response")
pred.data3.rev Strain Housing prob
1 WT STD 0.7102273
2 WT ENR 0.7637795
3 dTg STD 0.7025316
4 dTg ENR 0.6368421
5 PS1dE9 STD 0.6818182
6 PS1dE9 ENR 0.8265896
7 APPswe STD 0.6416185
8 APPswe ENR 0.7356322
Results
Results table can be seen here
Strategy Overview plot
knitr::include_graphics("strategy.png")Visualization results log. reg
2D - Age group 3
setwd("C:/Google/Uni/Bachelorarbeit/R/Analysis")
probs=read_excel("results_logistic_new.xlsx")
myColors = brewer.pal(4,"Set1")
names(myColors)=levels(probs$Housing)
colScale=scale_colour_manual(name="Housing",values=myColors)
probs$`Experiment_Phase`=as.factor(probs$`Experiment_Phase`)
probs3=filter(probs, Age_group=='3' & Model=='STRAIN*HOUSING')
gg = ggplot(probs3, mapping=aes(x=Strain, y=Probability, color=Housing)) + geom_jitter() + facet_grid(~Experiment_Phase) + labs(x="Strain", y="P(strategy.class 1)", title="Probability of 3 months old mice using Strategy class 1")
gg=gg+colScale
ggplotly(p=gg, height=400, width=800)Strain*Housing interaction model used for predictions.
2D - Age group 13-14
probs13=filter(probs, Age_group=='13-14')
gg = ggplot(probs13, mapping=aes(x=Strain, y=Probability, color=Housing)) + geom_jitter() + facet_grid(~Experiment_Phase) + labs(x="Strain", y="P(strategy.class 1)", title="Probability of 13-14 months old mice using Strategy class 1")
gg=gg+colScale
ggplotly(gg, height=400, width=800)Strain*Housing interaction model used for predictions of REV and BOTH phases. In the ACQ experiment phase, the additive model (Strain+Housing) shows the best fit. Take a look here
2D - Age group 17-25
probs17=filter(probs, Age_group=='17-25')
gg = ggplot(probs17, mapping=aes(x=Strain, y=Probability, color=Housing)) + geom_jitter() + facet_grid(~Experiment_Phase) + labs(x="Strain", y="P(strategy.class 1)", title="Probability of 17-25 months old mice using Strategy class 1", caption="test")
gg=gg+colScale
ggplotly(gg, height=400, width=800)Strategy.class ~ Strain and Strategy.class ~ Housing models were used separately for ACQ and Both experiment phases. REV phase has best model fit with the Strategy.class ~ Strain*Housing interaction model.
3D Surface Plot
x=c("WT","dTg","PS1dE9","APPswe")
y=c("STD","ENR","ACQ STD","ACQ ENR", "REV STD", "REV ENR")
z=rbind(
c(0.1590389,-0.0544041,0.0931034,0.0140845),
c(0.137224,0.0010616,0.2090069,0.1390805),
c(0.1245211,-0.2324561,0.0328185,-0.0731225),
c(0.0526316,-0.0907473,0.1307692,0.0747126),
c(0.2102273,0.2025316,0.1818182,0.1416185),
c(0.2637795,0.1368421,0.3265896,0.2356322)
)
z2=rbind(
c(0,0,0,0),c(0,0,0,0),c(0,0,0,0),c(0,0,0,0),c(0,0,0,0),c(0,0,0,0))
ebene= plot_ly(type="surface", x=~x, y=~y, z=~z)
ebene= ebene %>% add_surface(z=~z2)
ebene= ebene %>% layout( title='Probability of Strategy class 1 in 3 months old mice compared to p=0.5')
ebeneInteractive plot created with plotly(Sievert et al., 2021) library.
testing citations(Garthe et al., 2016)
RTrack package used(Overall, 2020)
Thresholded Logistic regression
Strategy Legend
- 1 - thigmotaxis
- 2 - circling
- 3 - random path
- 4 - scanning
- 5 - chaining
- 6 - directed search
- 7 - corrected search
- 8 - direct path
- 9 - perseverance
Strategies 1-5 are less hippocampus-dependent, ‘unspatial’ and therefore get strategy.class = 0. In contrast to that, strategies 6-9 are more hippocampus-dependent, ‘spatial’ and get strategy.class = 1 assigned.
All probabilities in the following codes relate to choosing strategy.class = 1.
setwd("C:/Google/Uni/Bachelorarbeit/R/Analysis")
ogistic.data=read_excel("logistic_reg_thresh.xlsx")Age group 17-25 Housing
ogistic.data.1725=filter(ogistic.data, Age_group1725=='1')fitting different logistic regression models with increasing complexity
simple model including housing only
ogreg.1725.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = ogistic.data.1725)simple model including Strain only
ogreg.1725.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = ogistic.data.1725)additive model including all factors
ogreg.1725.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = ogistic.data.1725)interaction model including all factors
ogreg.1725.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = ogistic.data.1725)Model comparisons using the anova function
anova(ogreg.1725.add.1b, ogreg.1725.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 932 1124.8
2 934 1168.0 -2 -43.211 4.139e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model including Strain better than model including housing
anova(ogreg.1725.add.2, ogreg.1725.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 931 1123.7
2 932 1124.8 -1 -1.068 0.3014
adding factor housing does not improve the model
anova(ogreg.1725.int, ogreg.1725.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 928 1118.0
2 932 1124.8 -4 -6.7896 0.1474
interaction model not better than additive model simple model including Strain only is the minimal adequate model
summary of minimal adequate model
summary(ogreg.1725.add.1b)
Call:
glm(formula = strategy.class ~ Strain, family = binomial, data = ogistic.data.1725)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.6554 -1.0524 0.7657 0.7657 1.3078
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.69315 0.18058 3.838 0.000124 ***
StraindTg -0.99462 0.25461 -3.906 9.37e-05 ***
StrainPS1dE9 0.03774 0.26570 0.142 0.887047
StrainWT 0.38380 0.20539 1.869 0.061669 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1171.2 on 935 degrees of freedom
Residual deviance: 1124.8 on 932 degrees of freedom
AIC: 1132.8
Number of Fisher Scoring iterations: 4
exp(coef(ogreg.1725.add.1b)) (Intercept) StraindTg StrainPS1dE9 StrainWT
2.000000 0.369863 1.038462 1.467857
impact of predictor “Strain”
pre.data <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pre.data$prob <- predict(ogreg.1725.add.1b, newdata = pre.data, type = "response")
pre.data Strain prob
1 WT 0.7459165
2 dTg 0.4251969
3 PS1dE9 0.6750000
4 APPswe 0.6666667
impact of predictor “housing”
pre.data2 <- data.frame(Housing=c("STD","ENR"))
pre.data2$prob <- predict(ogreg.1725.add.1a, newdata = pre.data2, type = "response")
pre.data2 Housing prob
1 STD 0.7075665
2 ENR 0.6532438
Age group 13-14 Strain x Housing effects
ogistic.data.1314=filter(ogistic.data, Age_group1314=='1')fitting different logistic regression models with increasing complexity simple model including housing only
ogreg.1314.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = ogistic.data.1314)simple model including Strain only
ogreg.1314.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = ogistic.data.1314)additive model including all factors
ogreg.1314.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = ogistic.data.1314)interaction model including all factors
ogreg.1314.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = ogistic.data.1314)model comparisons using the anova function
anova(ogreg.1314.add.1b, ogreg.1314.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 868 1024.4
2 868 1117.1 0 -92.65
no Df, same model fit?
anova(ogreg.1314.add.2, ogreg.1314.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 867 1023.8
2 868 1024.4 -1 -0.58952 0.4426
additive model shows significantly better fit (Pr=0.01295)
anova(ogreg.1314.int, ogreg.1314.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 866 1015.5
2 868 1024.4 -2 -8.9111 0.01161 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than simple Strain model (Pr=0.00248) interaction model including Strain*Housing is the best fitting model
summary of minimal adequate model
summary(ogreg.1314.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = ogistic.data.1314)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.9169 -1.0996 0.5890 0.7732 1.2573
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.1859 0.1403 -1.325 0.18514
HousingSTD 0.2720 0.2030 1.339 0.18041
StrainWT 1.8496 0.2176 8.501 < 2e-16 ***
HousingSTD:StrainWT -0.8813 0.3064 -2.877 0.00402 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1118.3 on 869 degrees of freedom
Residual deviance: 1015.5 on 866 degrees of freedom
AIC: 1023.5
Number of Fisher Scoring iterations: 4
exp(coef(ogreg.1314.int)) (Intercept) HousingSTD StrainWT HousingSTD:StrainWT
0.8303571 1.3125529 6.3575894 0.4142512
impact of predictor "Strain*Housing"
pre.data1314 <- data.frame(Strain=c("WT", "WT","dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pre.data1314$prob <- predict(ogreg.1314.int, newdata = pre.data1314, type = "response")
pre.data1314 Strain Housing prob
1 WT STD 0.7416268
2 WT ENR 0.8407407
3 dTg STD 0.5215054
4 dTg ENR 0.4536585
Age group 3 Strain x Housing
ogistic.data.3=filter(ogistic.data, Age_group3=='1')fitting different logistic regression models with increasing complexity simple model including housing only
ogreg.3.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = ogistic.data.3)simple model including Strain only
ogreg.3.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = ogistic.data.3)additive model including all factors
ogreg.3.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = ogistic.data.3)interaction model including all factors
ogreg.3.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = ogistic.data.3)comparisons between model using the anova function
anova(ogreg.3.add.1b, ogreg.3.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 2393 2730.5
2 2395 2803.6 -2 -73.096 < 2.2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model with Strain only is really good (Pr=3.245e-13)
anova(ogreg.3.add.2, ogreg.3.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 2392 2726.2
2 2393 2730.5 -1 -4.2311 0.03969 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adding factor housing also has good fit (Pr=1.945e-5)
anova(ogreg.3.int, ogreg.3.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 2389 2724.1
2 2393 2730.5 -4 -6.3947 0.1715
additive model better than interaction model (Pr=5.648e-6) additive model is the best
summary of Strain only model
summary(ogreg.3.add.1b)
Call:
glm(formula = strategy.class ~ Strain, family = binomial, data = ogistic.data.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.8414 -1.3582 0.7065 0.8176 1.0068
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.92408 0.08834 10.461 < 2e-16 ***
StraindTg -0.50857 0.12243 -4.154 3.27e-05 ***
StrainPS1dE9 0.33659 0.12929 2.603 0.00923 **
StrainWT 0.56859 0.14248 3.991 6.59e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 2805.7 on 2396 degrees of freedom
Residual deviance: 2730.5 on 2393 degrees of freedom
AIC: 2738.5
Number of Fisher Scoring iterations: 4
exp(coef(ogreg.3.add.1b)) (Intercept) StraindTg StrainPS1dE9 StrainWT
2.5195531 0.6013573 1.4001601 1.7657813
summary of additive model model
summary(ogreg.3.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = ogistic.data.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.8573 -1.2841 0.6659 0.7928 1.0743
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.9963 0.1194 8.343 < 2e-16 ***
HousingSTD -0.1629 0.1776 -0.917 0.35906
StraindTg -0.4404 0.1665 -2.645 0.00816 **
StrainPS1dE9 0.3971 0.1791 2.216 0.02666 *
StrainWT 0.4506 0.2058 2.190 0.02854 *
HousingSTD:StraindTg -0.1456 0.2462 -0.592 0.55417
HousingSTD:StrainPS1dE9 -0.1140 0.2595 -0.440 0.66027
HousingSTD:StrainWT 0.2445 0.2866 0.853 0.39374
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 2805.7 on 2396 degrees of freedom
Residual deviance: 2724.1 on 2389 degrees of freedom
AIC: 2740.1
Number of Fisher Scoring iterations: 4
exp(coef(ogreg.3.int)) (Intercept) HousingSTD StraindTg
2.7083333 0.8496756 0.6437870
StrainPS1dE9 StrainWT HousingSTD:StraindTg
1.4874725 1.5692308 0.8644712
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
0.8922211 1.2769194
impact of predictor “Strain”
pre.data3 <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pre.data3$prob <- predict(ogreg.3.add.1b, newdata = pre.data3, type = "response")
pre.data3 Strain prob
1 WT 0.8164794
2 dTg 0.6024096
3 PS1dE9 0.7791411
4 APPswe 0.7158730
impact of predictors “Strain + Housing”
pre.data3x <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pre.data3x$prob <- predict(ogreg.3.add.2, newdata = pre.data3x, type = "response")
pre.data3x Strain Housing prob
1 WT STD 0.8040861
2 WT ENR 0.8327355
3 dTg STD 0.5768254
4 dTg ENR 0.6231321
5 PS1dE9 STD 0.7611506
6 PS1dE9 ENR 0.7944739
7 APPswe STD 0.6935843
8 APPswe ENR 0.7330278
The full overview of the logistic regression results table is here.
Age group 17-25 acquisition Strain
ogistic.data.1725.acq=filter(ogistic.data.1725, `_Day`=='1'|`_Day`=='2'|`_Day`=='3'|`_Day`=='4'|`_Day`=='5'|`_Day`=='6')fitting different logistic regression models with increasing complexity
simple model including housing only
ogreg.1725.acq.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = ogistic.data.1725.acq)simple model including Strain only
ogreg.1725.acq.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = ogistic.data.1725.acq)additive model including all factors
ogreg.1725.acq.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = ogistic.data.1725.acq)interaction model including all factors
ogreg.1725.acq.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = ogistic.data.1725.acq)Model comparisons using the anova function
anova(ogreg.1725.acq.add.1b, ogreg.1725.acq.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 552 733.82
2 554 752.57 -2 -18.747 8.493e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model including Strain better than model including housing
anova(ogreg.1725.acq.add.2, ogreg.1725.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 551 733.82
2 552 733.82 -1 -0.0068548 0.934
adding factor housing does not improve the model
anova(ogreg.1725.acq.int, ogreg.1725.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 548 730.06
2 552 733.82 -4 -3.7677 0.4384
summary(ogreg.1725.acq.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = ogistic.data.1725.acq)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.4516 -1.3893 0.9260 0.9612 1.6394
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.1719 0.3393 -0.506 0.6125
HousingSTD 0.6419 0.4431 1.448 0.1475
StraindTg -0.1959 0.4573 -0.428 0.6684
StrainPS1dE9 0.6574 0.4649 1.414 0.1573
StrainWT 0.7967 0.3796 2.099 0.0358 *
HousingSTD:StraindTg -1.3156 0.7183 -1.832 0.0670 .
HousingSTD:StrainPS1dE9 -0.6013 0.6479 -0.928 0.3534
HousingSTD:StrainWT -0.7342 0.5001 -1.468 0.1421
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 752.70 on 555 degrees of freedom
Residual deviance: 730.06 on 548 degrees of freedom
AIC: 746.06
Number of Fisher Scoring iterations: 4
exp(coef(ogreg.1725.acq.int)) (Intercept) HousingSTD StraindTg
0.8421053 1.9000000 0.8221154
StrainPS1dE9 StrainWT HousingSTD:StraindTg
1.9296875 2.2181604 0.2683179
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
0.5481159 0.4798810
impact of predictor “Strain”
pre.data.17.acq <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pre.data.17.acq$prob <- predict(ogreg.1725.acq.add.1b, newdata = pre.data.17.acq, type = "response")
pre.data.17.acq Strain prob
1 WT 0.6400000
2 dTg 0.3582090
3 PS1dE9 0.6233766
4 APPswe 0.5517241
impact of predictor “Housing”
pre.data.17.acq <- data.frame(Housing=c("STD","ENR"))
pre.data.17.acq$prob <- predict(ogreg.1725.acq.add.1a, newdata = pre.data.17.acq, type = "response")
pre.data.17.acq Housing prob
1 STD 0.5971731
2 ENR 0.5824176
Age group 17-25 reversal Strain
ogistic.data.1725.rev=filter(ogistic.data.1725, `_Day`=='7'|`_Day`=='8'|`_Day`=='9'|`_Day`=='10')fitting different logistic regression models with increasing complexity
simple model including housing only
ogreg.1725.rev.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = ogistic.data.1725.rev)simple model including Strain only
ogreg.1725.rev.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = ogistic.data.1725.rev)additive model including all factors
ogreg.1725.rev.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = ogistic.data.1725.rev)interaction model including all factors
ogreg.1725.rev.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = ogistic.data.1725.rev)Model comparisons using the anova function
anova(ogreg.1725.rev.add.1b, ogreg.1725.rev.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 376 319.30
2 378 357.43 -2 -38.128 5.254e-09 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model including Strain better than model including housing
anova(ogreg.1725.rev.add.2, ogreg.1725.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 375 316.76
2 376 319.30 -1 -2.5396 0.111
adding factor housing does not improve the model
anova(ogreg.1725.rev.int, ogreg.1725.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 372 290.8
2 376 319.3 -4 -28.505 9.852e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than additive model
summary of minimal adequate model
summary(ogreg.1725.rev.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = ogistic.data.1725.rev)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.2035 0.4298 0.4895 0.4895 1.6176
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 17.57 989.05 0.018 0.986
HousingSTD -16.18 989.05 -0.016 0.987
StraindTg -18.56 989.05 -0.019 0.985
StrainPS1dE9 -16.54 989.05 -0.017 0.987
StrainWT -15.23 989.05 -0.015 0.988
HousingSTD:StraindTg 19.07 989.05 0.019 0.985
HousingSTD:StrainPS1dE9 16.49 989.05 0.017 0.987
HousingSTD:StrainWT 15.91 989.05 0.016 0.987
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 363.07 on 379 degrees of freedom
Residual deviance: 290.80 on 372 degrees of freedom
AIC: 306.8
Number of Fisher Scoring iterations: 16
exp(coef(ogreg.1725.rev.int)) (Intercept) HousingSTD StraindTg
4.254481e+07 9.401851e-08 8.705418e-09
StrainPS1dE9 StrainWT HousingSTD:StraindTg
6.581296e-08 2.428812e-07 1.914517e+08
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
1.443485e+07 8.087436e+06
impact of predictor “Strain”
pre.data.17.revs <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pre.data.17.revs$prob <- predict(ogreg.1725.rev.int, newdata = pre.data.17.revs, type = "response")
pre.data.17.revs Strain Housing prob
1 WT STD 0.8870968
2 WT ENR 0.9117647
3 dTg STD 0.8695652
4 dTg ENR 0.2702703
5 PS1dE9 STD 0.7916667
6 PS1dE9 ENR 0.7368421
7 APPswe STD 0.8000000
8 APPswe ENR 1.0000000
Age group 13-14 acquisition Strain x Housing
ogistic.data.acq.1314=filter(ogistic.data.1314, `_Day`=='1'|`_Day`=='2'|`_Day`=='3'|`_Day`=='4'|`_Day`=='5'|`_Day`=='6')fitting different logistic regression models with increasing complexity simple model including housing only
ogreg.1314.acq.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = ogistic.data.acq.1314)simple model including Strain only
ogreg.1314.acq.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = ogistic.data.acq.1314)additive model including all factors
ogreg.1314.acq.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = ogistic.data.acq.1314)interaction model including all factors
ogreg.1314.acq.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = ogistic.data.acq.1314)comparisons between model using the anova function
anova(ogreg.1314.acq.add.1b, ogreg.1314.acq.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 506 643.40
2 506 691.75 0 -48.349
model with Strain only is good
anova(ogreg.1314.acq.add.2, ogreg.1314.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 505 641.78
2 506 643.40 -1 -1.6198 0.2031
adding factor housing also has good fit
anova(ogreg.1314.acq.int, ogreg.1314.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 504 638.28
2 506 643.40 -2 -5.1186 0.07736 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Strain model is best
summary of interactive model
summary(ogreg.1314.acq.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = ogistic.data.acq.1314)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.7138 -1.0447 0.7235 0.9323 1.3654
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.4318 0.1816 -2.377 0.0174 *
HousingSTD 0.1113 0.2671 0.417 0.6769
StrainWT 1.6386 0.2648 6.189 6.07e-10 ***
HousingSTD:StrainWT -0.7099 0.3800 -1.868 0.0617 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 693.42 on 507 degrees of freedom
Residual deviance: 638.28 on 504 degrees of freedom
AIC: 646.28
Number of Fisher Scoring iterations: 4
exp(coef(ogreg.1314.acq.int)) (Intercept) HousingSTD StrainWT HousingSTD:StrainWT
0.6493506 1.1177419 5.1480000 0.4916989
impact of predictors “Strain”
pre.data1314.acq <- data.frame(Strain=c("WT","WT", "dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pre.data1314.acq$prob <- predict(ogreg.1314.acq.add.1b, newdata = pre.data1314.acq, type = "response")
pre.data1314.acq Strain Housing prob
1 WT STD 0.7153285
2 WT ENR 0.7153285
3 dTg STD 0.4059829
4 dTg ENR 0.4059829
impact of predictors “Housing”
pre.data1314.acq <- data.frame(Strain=c("WT","WT", "dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pre.data1314.acq$prob <- predict(ogreg.1314.acq.add.1a, newdata = pre.data1314.acq, type = "response")
pre.data1314.acq Strain Housing prob
1 WT STD 0.5414847
2 WT ENR 0.5985663
3 dTg STD 0.5414847
4 dTg ENR 0.5985663
Age group 13-14 reversal Strain x Housing
ogistic.data.rev.1314=filter(ogistic.data.1314, `_Day`=='7'|`_Day`=='8'|`_Day`=='9'|`_Day`=='10')fitting different logistic regression models with increasing complexity simple model including housing only
ogreg.1314.rev.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = ogistic.data.rev.1314)simple model including Strain only
ogreg.1314.rev.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = ogistic.data.rev.1314)additive model including all factors
ogreg.1314.rev.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = ogistic.data.rev.1314)interaction model including all factors
ogreg.1314.rev.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = ogistic.data.rev.1314)comparisons between model using the anova function
anova(ogreg.1314.rev.add.1b, ogreg.1314.rev.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 360 337.23
2 360 384.85 0 -47.62
anova(ogreg.1314.rev.add.2, ogreg.1314.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 359 337.11
2 360 337.23 -1 -0.11714 0.7322
adding factor does not improve model
anova(ogreg.1314.rev.int, ogreg.1314.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 358 333.32
2 360 337.23 -2 -3.9027 0.1421
Strain model is the best
summary of interaction model
summary(ogreg.1314.rev.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = ogistic.data.rev.1314)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.3200 0.3747 0.3747 0.9145 1.0913
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.2059 0.2277 0.904 0.3659
HousingSTD 0.4496 0.3288 1.367 0.1715
StrainWT 2.4152 0.4312 5.601 2.13e-08 ***
HousingSTD:StrainWT -1.1378 0.5884 -1.934 0.0532 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 384.89 on 361 degrees of freedom
Residual deviance: 333.32 on 358 degrees of freedom
AIC: 341.32
Number of Fisher Scoring iterations: 5
exp(coef(ogreg.1314.rev.int)) (Intercept) HousingSTD StrainWT HousingSTD:StrainWT
1.2285714 1.5676141 11.1918605 0.3205376
impact of predictors “Strain”
pre.data1314.rev <- data.frame(Strain=c("WT","WT", "dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pre.data1314.rev$prob <- predict(ogreg.1314.rev.add.1b, newdata = pre.data1314.rev, type = "response")
pre.data1314.rev Strain Housing prob
1 WT STD 0.9073171
2 WT ENR 0.9073171
3 dTg STD 0.6050955
4 dTg ENR 0.6050955
impact of predictors “Housing”
pre.data1314.rev <- data.frame(Strain=c("WT","WT", "dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pre.data1314.rev$prob <- predict(ogreg.1314.rev.add.1a, newdata = pre.data1314.rev, type = "response")
pre.data1314.rev Strain Housing prob
1 WT STD 0.7710843
2 WT ENR 0.7806122
3 dTg STD 0.7710843
4 dTg ENR 0.7806122
Age group 3 acquisition Strain x Housing
ogistic.data.acq.3=filter(ogistic.data.3, `_Day`=='1'|`_Day`=='2'|`_Day`=='3'|`_Day`=='4'|`_Day`=='5'|`_Day`=='6')fitting different logistic regression models with increasing complexity simple model including housing only
ogreg.3.acq.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = ogistic.data.acq.3)simple model including Strain only
ogreg.3.acq.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = ogistic.data.acq.3)additive model including all factors
ogreg.3.acq.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = ogistic.data.acq.3)interaction model including all factors
ogreg.3.acq.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = ogistic.data.acq.3)comparisons between model using the anova function
anova(ogreg.3.acq.add.1b, ogreg.3.acq.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1398 1727.9
2 1400 1804.8 -2 -76.907 < 2.2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model with Strain only is really good
anova(ogreg.3.acq.add.2, ogreg.3.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1397 1722.5
2 1398 1727.9 -1 -5.3748 0.02043 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adding factor housing also has good fit
anova(ogreg.3.acq.int, ogreg.3.acq.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1394 1712.5
2 1398 1727.9 -4 -15.461 0.003835 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than additive model interaction model is the best
summary of interaction model
summary(ogreg.3.acq.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = ogistic.data.acq.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.7971 -1.2746 0.7551 0.9157 1.4284
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.6523 0.1424 4.581 4.63e-06 ***
HousingSTD -0.1133 0.2203 -0.514 0.6070
StraindTg -0.4268 0.2048 -2.084 0.0372 *
StrainPS1dE9 0.4203 0.2147 1.958 0.0502 .
StrainWT 0.4566 0.2487 1.836 0.0663 .
HousingSTD:StraindTg -0.6852 0.3158 -2.170 0.0300 *
HousingSTD:StrainPS1dE9 -0.1545 0.3173 -0.487 0.6264
HousingSTD:StrainWT 0.3974 0.3519 1.129 0.2588
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1807.0 on 1401 degrees of freedom
Residual deviance: 1712.5 on 1394 degrees of freedom
AIC: 1728.5
Number of Fisher Scoring iterations: 4
exp(coef(ogreg.3.acq.int)) (Intercept) HousingSTD StraindTg
1.9200000 0.8928571 0.6526104
StrainPS1dE9 StrainWT HousingSTD:StraindTg
1.5224359 1.5787760 0.5039771
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
0.8568804 1.4879242
impact of predictors “Strain x Housing”
pre.data3.acq <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pre.data3.acq$prob <- predict(ogreg.3.acq.int, newdata = pre.data3.acq, type = "response")
pre.data3.acq Strain Housing prob
1 WT STD 0.8010753
2 WT ENR 0.7519380
3 dTg STD 0.3605442
4 dTg ENR 0.5561497
5 PS1dE9 STD 0.6910112
6 PS1dE9 ENR 0.7450980
7 APPswe STD 0.6315789
8 APPswe ENR 0.6575342
Age group 3 reversal Strain x Housing
ogistic.data.rev.3=filter(ogistic.data.3, `_Day`=='7'|`_Day`=='8'|`_Day`=='9'|`_Day`=='10')fitting different logistic regression models with increasing complexity simple model including housing only
ogreg.3.rev.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = ogistic.data.rev.3)simple model including Strain only
ogreg.3.rev.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = ogistic.data.rev.3)additive model including all factors
ogreg.3.rev.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = ogistic.data.rev.3)interaction model including all factors
ogreg.3.rev.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = ogistic.data.rev.3)comparisons between model using the anova function
anova(ogreg.3.rev.add.1b, ogreg.3.rev.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 991 894.74
2 993 903.30 -2 -8.5607 0.01384 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model with Strain only is really good (Pr=3.245e-13)
anova(ogreg.3.rev.add.2, ogreg.3.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 990 894.39
2 991 894.74 -1 -0.35067 0.5537
adding factor housing also has good fit (Pr=1.945e-5)
anova(ogreg.3.rev.int, ogreg.3.rev.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 987 889.61
2 991 894.74 -4 -5.134 0.2738
Strain is best model
summary of interaction model
summary(ogreg.3.rev.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = ogistic.data.rev.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.0688 0.5003 0.5769 0.6242 0.7651
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.7091 0.2371 7.207 5.73e-13 ***
HousingSTD -0.4510 0.3222 -1.400 0.1615
StraindTg -0.6303 0.3093 -2.038 0.0416 *
StrainPS1dE9 0.2681 0.3457 0.776 0.4380
StrainWT 0.3058 0.3882 0.788 0.4308
HousingSTD:StraindTg 0.9091 0.4516 2.013 0.0441 *
HousingSTD:StrainPS1dE9 0.1642 0.4789 0.343 0.7318
HousingSTD:StrainWT 0.2081 0.5168 0.403 0.6872
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 903.56 on 994 degrees of freedom
Residual deviance: 889.61 on 987 degrees of freedom
AIC: 905.61
Number of Fisher Scoring iterations: 4
exp(coef(ogreg.3.rev.int)) (Intercept) HousingSTD StraindTg
5.5238095 0.6369732 0.5324544
StrainPS1dE9 StrainWT HousingSTD:StraindTg
1.3074713 1.3577586 2.4820511
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
1.1783970 1.2313136
impact of predictors “Strain”
pre.data3.rev <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pre.data3.rev$prob <- predict(ogreg.3.rev.add.1b, newdata = pre.data3.rev, type = "response")
pre.data3.rev Strain Housing prob
1 WT STD 0.8675799
2 WT ENR 0.8675799
3 dTg STD 0.7813765
4 dTg ENR 0.7813765
5 PS1dE9 STD 0.8629630
6 PS1dE9 ENR 0.8629630
7 APPswe STD 0.8146718
8 APPswe ENR 0.8146718
impact of predictors “Housing”
pre.data3.rev <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pre.data3.rev$prob <- predict(ogreg.3.rev.add.1a, newdata = pre.data3.rev, type = "response")
pre.data3.rev Strain Housing prob
1 WT STD 0.8248945
2 WT ENR 0.8368522
3 dTg STD 0.8248945
4 dTg ENR 0.8368522
5 PS1dE9 STD 0.8248945
6 PS1dE9 ENR 0.8368522
7 APPswe STD 0.8248945
8 APPswe ENR 0.8368522
Thresholded Visualization results log. reg
2D - Age group 3
setwd("C:/Google/Uni/Bachelorarbeit/R/Analysis")
probs=read_excel("results_logistic_thresh.xlsx")
myColors = brewer.pal(4,"Set1")
names(myColors)=levels(probs$Housing)
colScale=scale_colour_manual(name="Housing",values=myColors)
probs$`Experiment_Phase`=as.factor(probs$`Experiment_Phase`)
probs3=filter(probs, Age_group=='3')
gg = ggplot(probs3, mapping=aes(x=Strain, y=Probability, color=Housing)) + geom_jitter() + facet_grid(~Experiment_Phase) + labs(x="Strain", y="P(strategy.class 1)", title="Probability of 3 months old mice using Strategy class 1")
gg= gg+colScale
ggplotly(p=gg, height=400, width=800)For ACQ Phase, Strain*Housing interaction model was used. For BOTH Phases, Strain+Housing additive model was used for predictions and for REV the simple strategy.class ~ Strain and strategy.class ~ Housing models were used separately.
2D - Age group 13-14
probs13=filter(probs, Age_group=='13-14')
gg = ggplot(probs13, mapping=aes(x=Strain, y=Probability, color=Housing)) + geom_jitter() + facet_grid(~Experiment_Phase) + labs(x="Strain", y="P(strategy.class 1)", title="Probability of 13-14 months old mice using Strategy class 1")
gg=gg+colScale
ggplotly(gg, height=400, width=800)Strain*Housing interaction model was used for predictions of BOTH phases. In the ACQ and REV experiment phases, the simple models (strategy.class ~ Strain and strategy.class ~ Housing) showed the best fit. Take a look here
2D - Age group 17-25
probs17=filter(probs, Age_group=='17-25')
gg = ggplot(probs17, mapping=aes(x=Strain, y=Probability, color=Housing)) + geom_jitter() + facet_grid(~Experiment_Phase) + labs(x="Strain", y="P(strategy.class 1)", title="Probability of 17-25 months old mice using Strategy class 1", caption="test")
gg=gg+colScale
ggplotly(gg, height=400, width=800)For the ACQ AND BOTH phases, the simple strategy.class ~ Strain and strategy.class ~ Housing models were used and for the REV phase, the interactive Strain*Housing model showed the best fit and was therefore used for the predictions.